package com.hbx.config;

import com.hbx.auth.AuthInceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
 * @Author:hbx
 *
 * */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Bean
    public AuthInceptor authInceptor(){
        return new AuthInceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInceptor())
                .excludePathPatterns("/auth/login")
                .excludePathPatterns("/user/active/**")
                .excludePathPatterns("/user/checkEmailExist")
                .excludePathPatterns("/user/checkUsernameExist")
                .excludePathPatterns("/user/register")
                .excludePathPatterns("/base/**")
                .excludePathPatterns("/druid/**")
                .excludePathPatterns("/doc.html","/service-worker.js","/swagger-resources","/webjars/**")
                .addPathPatterns("/**");
    }
}
